package com.duanzz.config;

import org.apache.ibatis.cache.Cache;
import org.apache.ibatis.cache.CacheKey;

import java.util.HashMap;
import java.util.Map;

/**
 * @author duanzz
 * @description
 * @date 2021/1/7
 */
public class MyLevel2Cache implements Cache {

    private static Map<Long,Object> MAP = new HashMap<>();

    private String id;

    public MyLevel2Cache(String id) {
        this.id = id;
    }

    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public void putObject(Object key, Object value) {
        int i = key.hashCode();
        MAP.put((long) i,value);
    }

    @Override
    public Object getObject(Object key) {
        if(MAP.containsKey((long)key.hashCode())){
            return MAP.get((long)key.hashCode());
        }
        return null;
    }

    @Override
    public Object removeObject(Object key) {
        return null;
    }

    @Override
    public void clear() {

    }

    @Override
    public int getSize() {
        return 0;
    }
}
